<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>ficlose</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="fareyleni.html" title="fareyleni" />
    <link rel="next" href="filebit.html" title="filebit" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">ficlose</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="fareyleni.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="filebit.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="ficlose"></a>
      <div class="titlepage"></div>
      <a id="IndexFiclose" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">ficlose</span>
        </h2>
        <p>ficlose — 
      Closes a previously opened file.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp102580992"></a>
        <h2>Description</h2>
        <p>
      <span class="emphasis"><em>ficlose</em></span> can be used to close a file which was opened with <a class="link" href="fiopen.html" title="fiopen"><em class="citetitle">fiopen</em></a>.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp102583584"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>ficlose</strong></span> ihandle</pre>
        <pre class="synopsis"><span class="command"><strong>ficlose</strong></span> Sfilename</pre>
      </div>
      <div class="refsect1">
        <a id="idp102586880"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ihandle</em></span> -- a number which identifies this file (generated by a previous <a class="link" href="fiopen.html" title="fiopen"><em class="citetitle">fiopen</em></a>).
    </p>
        <p>
      <span class="emphasis"><em>Sfilename</em></span> -- A string in double quotes or string variable with the filename. The full path must be given if the file directory is not in the system PATH and is not present in the current directory.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp102590448"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>ficlose</em></span> closes a file which was previously opened with <a class="link" href="fiopen.html" title="fiopen"><em class="citetitle">fiopen</em></a>. <span class="emphasis"><em>ficlose</em></span> is only needed if you need to read a file written to during the same csound performance, since only when csound ends a performance does it close and save data in all open files. The opcode <span class="emphasis"><em>ficlose</em></span> is useful for instance if you want to save presets within files which you want to be accesible without having to terminate csound. 
    </p>
        <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Note">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Note]" src="images/note.png" />
              </td>
              <th align="left">Note</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>If you don't need this functionality it is safer not to call <span class="emphasis"><em>ficlose</em></span>, and just let csound close the files when it exits.</p>
              </td>
            </tr>
          </table>
        </div>
        <p>
      If a files closed with <span class="emphasis"><em>ficlose</em></span> is being accessed by another opcode (like <a class="link" href="fout.html" title="fout"><em class="citetitle">fout</em></a> or <a class="link" href="foutk.html" title="foutk"><em class="citetitle">foutk</em></a>), it will be closed later when it is no longer being used.
    </p>
        <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Warning">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Warning]" src="images/warning.png" />
              </td>
              <th align="left">Warning</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>This opcode should be used with care, as the file handle will become invalid, and will cause an init error when an opcode tries to access the closed file.</p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1">
        <a id="idp102599392"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the ficlose opcode. It uses the file <a class="ulink" href="examples/ficlose.csd" target="_top"><em class="citetitle">ficlose.csd</em></a>.
            </p>
        <div class="example">
          <a id="idp102601248"></a>
          <p class="title">
            <strong>Example 248. Example of the ficlose opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
 
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac     <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o ficlose.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>
 

<span class="ohdr">sr</span> <span class="op">=</span> 44100 
<span class="ohdr">ksmps</span> <span class="op">=</span> 32 
<span class="ohdr">nchnls</span> <span class="op">=</span> 2 
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1 

gihand <span class="opc">fiopen</span> "test1.txt", 0 

<span class="oblock">instr</span> 1

ires  <span class="opc">random</span>  0, 100
      <span class="opc">fouti</span> gihand, 0, 1, ires 
      <span class="opc">ficlose</span> gihand 

<span class="oblock">endin</span> 
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
 

<span class="stamnt">i</span> 1 0 1 

<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp102605536"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="fiopen.html" title="fiopen"><em class="citetitle">fiopen</em></a>,
      <a class="link" href="fout.html" title="fout"><em class="citetitle">fout</em></a>, 
      <a class="link" href="fouti.html" title="fouti"><em class="citetitle">fouti</em></a>, 
      <a class="link" href="foutir.html" title="foutir"><em class="citetitle">foutir</em></a>, 
      <a class="link" href="foutk.html" title="foutk"><em class="citetitle">foutk</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp102611424"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Gabriel Maldonado</td>
          </tr>
          <tr>
            <td>Italy</td>
          </tr>
          <tr>
            <td>1999</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in Csound version 5.02</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="fareyleni.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="filebit.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">fareyleni </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> filebit</td>
        </tr>
      </table>
    </div>
  </body>
</html>
